package com.java.module.fire.controller.admin;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.java.common.lang.annotation.Log;
import com.java.common.lang.domain.AjaxResult;
import com.java.common.lang.enums.BusinessTypeEnum;
import com.java.common.utils.WebKit;
import com.java.module.fire.domain.Like;
import com.java.module.fire.service.ILikeService;
import com.java.common.utils.poi.ExcelUtil;
import com.java.common.lang.domain.page.TableDataInfo;

/**
 * 收藏点赞Controller
 * 
 * @author Administrator
 * @date 2025-02-10
 */
@RestController("AdminLikeController")
@RequestMapping("/fire/like")
public class LikeController {
    @Autowired
    private ILikeService likeService;

    /**
     * 查询收藏点赞列表
     */
    @PreAuthorize("@ss.hasPermi('fire:like:list')")
    @GetMapping("/list")
    public TableDataInfo list(Like like) {
        WebKit.startPage();
        List<Like> list = likeService.selectLikeList(like);
        return WebKit.getDataTable(list);
    }

    /**
     * 导出收藏点赞列表
     */
    @PreAuthorize("@ss.hasPermi('fire:like:export')")
    @Log(title = "收藏点赞", businessType = BusinessTypeEnum.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Like like) {
        List<Like> list = likeService.selectLikeList(like);
        ExcelUtil<Like> util = new ExcelUtil<Like>(Like.class);
        return util.exportExcel(list, "like");
    }

    /**
     * 获取收藏点赞详细信息
     */
    @PreAuthorize("@ss.hasPermi('fire:like:query')")
    @GetMapping(value = "/{likeId}")
    public AjaxResult getInfo(@PathVariable("likeId") Long likeId) {
        return AjaxResult.success(likeService.selectLikeById(likeId));
    }

    /**
     * 新增收藏点赞
     */
    @PreAuthorize("@ss.hasPermi('fire:like:add')")
    @Log(title = "收藏点赞", businessType = BusinessTypeEnum.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Like like) {
        return WebKit.toAjax(likeService.insertLike(like));
    }

    /**
     * 修改收藏点赞
     */
    @PreAuthorize("@ss.hasPermi('fire:like:edit')")
    @Log(title = "收藏点赞", businessType = BusinessTypeEnum.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Like like) {
        return WebKit.toAjax(likeService.updateLike(like));
    }

    /**
     * 删除收藏点赞
     */
    @PreAuthorize("@ss.hasPermi('fire:like:remove')")
    @Log(title = "收藏点赞", businessType = BusinessTypeEnum.DELETE)
	@DeleteMapping("/{likeIds}")
    public AjaxResult remove(@PathVariable Long[] likeIds) {
        return WebKit.toAjax(likeService.deleteLikeByIds(likeIds));
    }
}
